/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import beans.Recado;
import beans.Usuario;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 *
 * @author alexandre
 */
public class DAOMensagem {
    
    private EntityManager em;

    public DAOMensagem(EntityManager em) {
        this.em = em;
    }
    
    public List<Recado> buscarMsg(Usuario us){
        
        Query q = em.createQuery("SELECT r FROM Recado r WHERE r.userReceiver.id = " + us.getId());
        
        
        return q.getResultList();
    }
    
}
